package com.wb3.meta.api.core.controller;

import com.wb3.meta.api.core.service.GoodsInfoService;
import com.wb3.meta.api.core.vo.ReqGoodsInfoVo;
import com.wb3.meta.common.annotation.NoPermission;
import com.wb3.meta.common.annotation.RequireAuth;
import com.wb3.meta.common.authentication.RequestHolder;
import com.wb3.meta.common.plugin.BaseResultController;
import com.wb3.meta.common.pojo.ResultT;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "商城-商品相关接口")
@RequestMapping("base/goods/info")
public class GoodsInfoController extends BaseResultController<ReqGoodsInfoVo> {

    @Autowired
    private GoodsInfoService goodsInfoService;

    /**
     * 列表接口
     *
     * @param reqGoodsInfoVo fd
     */
//    @RequireAuth
    @Override
    @ApiOperation("列表接口")
    @GetMapping("list")
    public ResultT list(ReqGoodsInfoVo reqGoodsInfoVo) {
        reqGoodsInfoVo.setStatus(2);
        return goodsInfoService.getModelMapPage(reqGoodsInfoVo);
    }


    /**
     * 明细接口
     *
     * @param reqGoodsInfoVo
     */
//    @RequireAuth
    @Override
    @ApiOperation("详情接口")
    @GetMapping("detail")
    public ResultT detail(ReqGoodsInfoVo reqGoodsInfoVo) {
        return goodsInfoService.getResModelMapByConditions(reqGoodsInfoVo);
    }

    /**
     * 新增or更新接口
     *
     * @param reqGoodsInfoVo
     */
    @NoPermission
    @Override
    @ApiOperation("更新接口")
    @PostMapping("update")
    public ResultT saveOrUpdate(@RequestBody ReqGoodsInfoVo reqGoodsInfoVo) {
        return goodsInfoService.saveOrUpdate(reqGoodsInfoVo);
    }

    /**
     * 删除接口
     *
     * @param reqGoodsInfoVo
     */
    @NoPermission
    @Override
    @ApiOperation("删除接口")
    @PostMapping("delete")
    public ResultT delete(@RequestBody ReqGoodsInfoVo reqGoodsInfoVo) {
        return goodsInfoService.delete(reqGoodsInfoVo);
    }

//    @RequireAuth
//    @ApiOperation("购买前检查")
//    @PostMapping("buyCheckBefore")
//    public ResultT buyCheckBefore(@RequestBody ReqGoodsInfoVo reqGoodsInfoVo) {
//        return goodsInfoService.buyCheckBefore(reqGoodsInfoVo);
//    }

}
